The section describes the programming interface of the LPUART Peripheral driver.
More...
|
| status_t | lpuart_init (uint32_t lpuartInstance, const lpuart_user_config_t *lpuartUserConfig, lpuart_state_t *lpuartState) |
| | Initialize a LPUART instance for operation. More...
|
| |
| status_t | lpuart_send_data (lpuart_state_t *lpuartState, uint8_t *sendBuffer, uint32_t txByteCount, uint32_t timeout) |
| | Send data out through the LPUART module using a blocking method. More...
|
| |
| status_t | lpuart_send_data_async (lpuart_state_t *lpuartState, uint8_t *sendBuffer, uint32_t txByteCount) |
| | Send data out through the LPUART module using a non-blocking method. More...
|
| |
| status_t | lpuart_get_transmit_status (lpuart_state_t *lpuartState, uint32_t *bytesTransmitted) |
| | Returns whether the previous transmit has finished yet. More...
|
| |
| status_t | lpuart_get_receive_status (lpuart_state_t *lpuartState, uint32_t *bytesReceived) |
| | Returns whether the previous receive has finished yet. More...
|
| |
| void | lpuart_shutdown (lpuart_state_t *lpuartState) |
| | Shutdown the lpuart by disabling interrupts and transmitter/receiver. More...
|
| |
| status_t | lpuart_receive_data (lpuart_state_t *lpuartState, uint8_t *rxBuffer, uint32_t requestedByteCount, uint32_t timeout) |
| | Get data from the LPUART module using a blocking method. More...
|
| |
| status_t | lpuart_receive_data_async (lpuart_state_t *lpuartState, uint8_t *rxBuffer, uint32_t requestedByteCount) |
| | Get data from the LPUART module using a non-blocking method. More...
|
| |
| status_t | lpuart_abort_sending_data (lpuart_state_t *lpuartState) |
| | Terminates an asynchronous transmission early. More...
|
| |
| status_t | lpuart_abort_receiving_data (lpuart_state_t *lpuartState) |
| | Terminates an asynchronous receive early. More...
|
| |
Overview
The LPUART peripheral driver transfers data to and from external devices on the Low Power Universal Asynchronous Receiver/Transmitter (LPUART) serial bus. It provides a way to transmit or receive buffers of data with calls to a single function.
Device structures
The driver uses instantiations of the lpuart_tx_state_t and the lpuart_rx_state_t structure to maintain the current state of a particular LPUART instance module driver. The caller provides memory for the driver state structures during the initialization as the driver itself does not statically allocate memory. The structures are provided below:
typedef struct LpuartTxState {
uint32_t instance;
bool isTransmitInProgress;
bool isTransmitAsync;
const uint8_t * sendBuffer;
size_t remainingSendByteCount;
size_t transmittedByteCount;
uint8_t fifoEntryCount;
} lpuart_tx_state_t;
typedef struct LpuartRxState {
uint32_t instance;
bool isReceiveInProgress;
bool isReceiveAsync;
uint8_t * receiveBuffer;
size_t remainingReceiveByteCount;
size_t receivedByteCount;
uint8_t fifoEntryCount;
} lpuart_rx_state_t;
Initialization
To initialize the LPUART driver, call the
lpuart_init() function and pass the instance number of the LPUART peripheral you want to use. For instance, to use LPUART0 pass a value of 0 to the initialization function. In addition, you also have to pass a user configuration structure
lpuart_user_config_t shown here:
typedef struct LpuartUserConfig {
uint32_t baudRate;
Typically the user configures the
lpuart_user_config_t instantiation as an 8-bit-char, no-parity, 1-stop-bit (8-n-1) with a baud rate of 9600 bps. The user can easily modify the
lpuart_user_config_t instantiation to configure the LPUART peripheral to a different baud rate or character transfer features. This is a code example to set up a user LPUART configuration instantiation:
Transfers
The driver implements transmit and receive functions to transfer buffers of data. The driver supports two different modes for transferring data: blocking and non-blocking.The blocking transmit and receive functions are the
lpuart_send_data() and the
lpuart_receive_data().The non-blocking (async) transmit and receive functions are the
lpuart_send_data_async() and the
lpuart_receive_data_async().In all of these cases, the functions are interrupt driven.